﻿rem
	bbdoc: Contains current map
end rem
Type TMap
	Field map:TTile[,]
	Field mapW, mapH
	
	Function Create:TMap(mapW, mapH)
		Local d:TMap=New TMap
		Local i:Int
		Local j:Int
		
		d.map = New TTile[mapW, mapH]
		curmapW = mapW
		curmapH = mapH
		
		d.mapW = mapW
		d.mapH = mapH
		'Заполняем карту землей
		For i = 0 To mapW - 1
			For j = 0 To mapH - 1
				d.map[i, j] = TILE_EARTH
			Next
		Next
		'Стены по краям
		For i = 0 To mapW - 1
			d.map[i, 0] = TILE_WALL
			d.map[i, mapH - 1] = TILE_WALL
		Next
		For i = 0 To mapH - 1
			d.map[0, i] = TILE_WALL
			d.map[mapW - 1, i] = TILE_WALL
		Next
		d.map[5, 5] = TILE_WALL
		Return d
	End Function
	
	
	Method Draw()
		Local i, j:Int
		For i = 0 To mapW - 1
			For j = 0 To mapH - 1
				SetColor(map[i, j].colorR, map[i, j].colorG, map[i, j].colorB)
				camera.Draw(map[i, j].code, i, j)
			Next
		Next
		SetColor(255, 255, 255)
	End Method
End Type
